/**
 * 
 */
package com.an.jackjson;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

import redis.clients.jedis.Jedis;

/**
 * @author Administrator
 *
 */
public class getJson {

	public static void main(String[] args) {
		ObjectMapper objectMapper = new ObjectMapper();

		// 方法块，用于对JSON工具进行配置
		// json字符串为非双引号
		objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
		// json字符串中可以有vo中没有的字段
		objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
		
		UserData userData = new UserData();
		userData.setPhoneNumberA("A133013");
		userData.setPhoneNumberB("B144014");
		userData.setPhoneNumberX("X155015");
		String bindingId = "bingdingId-test-axcalling";
		userData.setBindingId(bindingId);
		String json = null;
		CacheKeyUtil cacheKeyUtil = new CacheKeyUtil();
		
		try {
			json = objectMapper.writeValueAsString(userData);
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(json);
		
		Jedis jedis = new Jedis("10.8.28.208");
		jedis.auth("AS@redis");
		String key  = cacheKeyUtil.getUserDataKey(bindingId);
		String r = jedis.set(key, json);
		System.out.println("r:" + r);
		System.out.println("key:" + key);
		System.out.println("value：" + json);
	}
}
